package com.wyh.seata.controller;

import com.wyh.seata.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pojo.CommonResult;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author wyh
 * @version 1.0
 * @date 2021/12/2 15:00
 */
@RestController
@Slf4j
public class AccountController {

    @Resource
    AccountService accountService;

    /**
     * 扣减账户余额
     */
    @PostMapping(value = "/account/deMoney")
    public CommonResult deMoney(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money){
        accountService.deMoney(userId, money);
        return new CommonResult(200, "扣减账户余额成功！");
    }
}
